<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>监听器</title>
</head>
<body>
<div id="app">
    <span>{{count}}</span>
    <button @click="addClick">+</button>
    <button @click="preClick">-</button>
</div>
</body>
<script src="../js/http_cdn.bootcdn.net_ajax_libs_vue_2.6.6_vue.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            count:1
        },
        methods: {
            addClick() {
                this.count++;
            },
            preClick() {
                this.count--;
            }
        },
        watch: {
            // 监听一个变量或者一个数组
            count(newValue, oldValue) {
                console.log(newValue,oldValue)
            }
        },
    })
</script>
</html>
